package com.maixun.lib_comment.extends

import android.widget.EditText
import com.scwang.smartrefresh.layout.SmartRefreshLayout
import com.scwang.smartrefresh.layout.constant.RefreshState

/**
 * 作者：Lmoumou
 * 时间：2020/9/7 15:17
 */
fun EditText.inputContent(content: String?) {
    this.setText(content)
    this.setSelection(content?.length ?: 0)
}

fun SmartRefreshLayout.stopRefresh(refreshSuc: Boolean, isLoadMore: Boolean = true) {
    if (this.state == RefreshState.Refreshing) {
        this.finishRefresh(refreshSuc)
    }

    if (isLoadMore) {
        this.finishLoadMore().setNoMoreData(false)
    } else {
        this.finishLoadMoreWithNoMoreData()
    }
}